<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table>
    <thead>
    <tr>
        <th>ID</th>
        <th>姓名</th>
        <th>年龄</th>
    </tr>
    </thead>
    <tbody id="body">

    </tbody>
</table>
</body>
<script>
    //需求：
    /*
      <tr>
      <td>1</td>
      <td>yqy</td>
      <td>12</td>
      </tr>
      <tr>
        <td>2</td>
        <td>yqy</td>
        <td>12</td>
      </tr>
    */
    //1.创建<tr>标签
    //2.遍历字典，并创建对应的td标签读取文本
    //3.将td加入tr中
    //4.将tr加入tbody中

    var dataList = [
        {id: 1, name: 'yqy', age: 20},
        {id: 2, name: 'yqy', age: 20},
        {id: 3, name: 'yqy', age: 20},
        {id: 4, name: 'yqy', age: 20},
        {id: 5, name: 'yqy', age: 20},
    ]

    for (var info of dataList) {
        //遍历每一个字典，并创建对应的tr
        var tr = document.createElement('tr');
        for (var key in info) {
            // 遍历字典的每一个键值对，并创建对应的td
            var value = info[key];
            console.log(value);
            var td = document.createElement('td')
            td.innerText = value;
            //td放入对应的tr标签
            tr.appendChild(td);
        }
        var id = document.getElementById('body');
        id.appendChild(tr);
    }
</script>
</html>